/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ActiveRecord;

import ActiveRecord.Newdb.Db;
import Buslog.SuperUser;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author degrave
 */
public class UserActiveRecord {

    
    public static SuperUser findUser(String name) {
        
        try {
            Connection c = Db.getInstance().getConnection();
            java.sql.Statement s = c.createStatement ();
            ResultSet rs = s.executeQuery ("select * from USERS where NAME = '" + name +"'");
            if(rs.next()){
            SuperUser man = new SuperUser(rs.getInt(1), rs.getString(2),rs.getString(3),rs.getInt(4),rs.getInt(5)) {};
            return man; 
            }                
        } 
        catch (SQLException ex) {
            Logger.getLogger(ActiveRecord.UserActiveRecord.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
